import { SHOW_MENU, HIDE_MENU, CHANGE_MENU_TITLE } from '../constants/menu'

const initialState = {
  list: [
    {key: 'all', value: '全部'},
    {key: 'good', value: '精华'},
    {key: 'share', value: '分享'},
    {key: 'ask', value: '问答'},
    {key: 'job', value: '招聘'},
    {key: 'dev', value: '客户端测试'}
  ],
  currentListItem: {
    key: 'all',
    value: '全部'
  },
  showMenu: false 
}

export default function menuReducer(state = initialState, action){
  switch(action.type){
    case SHOW_MENU:
      return {...state, showMenu: true}
    case HIDE_MENU:
      return {...state, showMenu: false}
    case CHANGE_MENU_TITLE:
      return {...state, currentListItem: action.currentListItem}
    default:
      return state
  }
}